﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;

namespace Vistas
{
    /// <summary>
    /// Lógica de interacción para VehiculosEnPlaya.xaml
    /// </summary>
    public partial class VehiculosEnPlaya : Window
    {
        string usu = "operador";
        public VehiculosEnPlaya()
        {
            InitializeComponent();
        }

        public VehiculosEnPlaya(string ger)
        {
            InitializeComponent();
            this.usu = ger;
        }

        private void button11_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Sector_Click(object sender, RoutedEventArgs e)
        {
            
            
                ToggleButton TB = (ToggleButton)sender;
                Border B = (Border)TB.Content;
                if (B.Background == Brushes.Green)
                {
                    MessageBox.Show("Sector Disponible. Registrar Entrada.");
                    // B.Background = Brushes.Red;

                }
                else
                {

                    if (B.Background == Brushes.Red)
                    {
                        MessageBox.Show("Sector Ocupado. Registrar Salida.");
                        // B.Background = Brushes.Green;

                    }
                    else
                    {
                        if ((B.Background == Brushes.DarkGray) && (this.usu == "gerente"))
                        {
                           // MessageBox.Show("Sector deshabilitado.");




                            string messageBoxText = "Confirma cambiar el estado del sector a DISPONIBLE?";
                            string mensaje = "Confirmación";
                            MessageBoxButton button = MessageBoxButton.YesNo;
                            MessageBoxImage icon = MessageBoxImage.Warning;


                            MessageBoxResult result = MessageBox.Show(messageBoxText, mensaje, button, icon);
                            switch (result)
                            {
                                case MessageBoxResult.Yes:
                                    B.Background = Brushes.Green;
                                    MessageBox.Show("El Cambio se realizo correctamente"); 
                                   // Close();
                                    break;

                                case MessageBoxResult.No:
                                    // User pressed Cancel button
                                    // ...
                                   //Close(); //si se coloca se cierra la venta Vehiculos en playa

                                    break;

                            }


                        }
                        else
                        {
                            MessageBox.Show("Sector deshabilitado.");
                        }

                    }
                }

           


            
      
        }



        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            b7.Background = Brushes.Red;
            // Valores que podrán ser leidos desde la BD
            //string fila = "B", asiento = "3";

            //string butaca = fila + asiento;
            //ToggleButton TB = FindName(butaca) as ToggleButton;
            //if (TB != null)
            //{
            //    TB.IsEnabled = true;
            //    Border B = (Border)TB.Content;
            //    B.Background = Brushes.Red;

            //}

        }
    }
}
